package edu.thu.studio.ormdesigner.outline.editpart;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import edu.thu.studio.ormdesigner.Activator;
import edu.thu.studio.ormdesigner.model.diagram.node.ViewNode;
import edu.thu.studio.ormdesigner.model.diagram.node.ViewNodeSet;
import edu.thu.studio.ormdesigner.util.Properties;

public class ViewNodeSetOutlineEditPart extends AbstractOutlineEditPart {
    
    /**
     * {@inheritDoc}
     */
    @Override
    @SuppressWarnings("rawtypes")
    protected List getModelChildren() {
        ViewNodeSet viewSet = (ViewNodeSet) this.getModel();
        
        List<ViewNode> list = new ArrayList<ViewNode>();
        
        for (ViewNode view : viewSet) {
            list.add(view);
        }
        
        Collections.sort(list);
        return list;
    }
    
    /**
     * {@inheritDoc}
     */
    @Override
    protected void refreshOutlineVisuals() {
        this.setWidgetText(Properties.outline_label_viewset + " (" + this.getModelChildren().size() + ")");
        this.setWidgetImage(Activator.getImage(Properties.icon_viewset));
    }
    
}
